<?php echo $this->Html->script('jquery.dataTables.js'); ?>
<script type="text/javascript">
    $(document).ready(function() {
        $('#browserList').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "<?php echo $this->Html->Url(array('controller' => 'Consigners', 'action' => 'indexdata')); ?>"
        });
    });
</script>   
   <div class="admin_left actions">

    <h3 style="font-size:20px;">Manage more</h3>

        <ul>
            <li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Consigners'), array('controller' => 'consigners', 'action' => 'index'),array('class' => 'consistentButton2')); ?> </li>
            <li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Suppliers'), array('controller' => 'suppliers', 'action' => 'index'),array('class' => 'consistentButton2')); ?> </li>
        </ul>
    </div>

<div id="pinkHeader" class="admin_right items index">

		<div id=breadcrumbAdmin>
	    	<?php $this->Html->addCrumb('Consigners', '/Consigners/index', array('style'=> ('text-decoration:underline; color:#EB1E70;'))); ?>
	        <?php echo $this->Html->getCrumbs(' > ', array( 'text' => 'Contacts', 'url' => array('controller' => 'suppliers', 'action' => 'index'), 'escape' => false)); ?>
	    </div>


    <div class="consigners index">

        <h2><?php echo __('Consigners'); ?></h2>

       <!-- <div id="search" style="text-align: left;">
            <?php
                echo $this->Form->create('Consigner',array('action' => 'search'));
                echo $this->Form->input('keyword', array('label' => 'Search for'));
            ?>
        </div>-->

       <p  class="actions" style="list-style-type:none; margin-bottom:2%;"><?php echo $this->Html->link(__('Add New Consigner'), array('action' => 'add')); ?></p>
	   
	   <table id="browserList" style="width:120%;" cellpadding="0" cellspacing="0" class="table table-bordered  table-hover">
    <thead>
        <tr>
            <th style="width:5%;">Id</th>
            <th>Name</th>
            <th>Email</th>
            <th>Phone</th>       
            <th style="width:20%;">Address</th>          
            <th style="width:20%;">Note</th>
			<th style="width:15%;" class="actions">Actions</th>            
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="4" class="dataTables_empty">Loading data from server...</td>
        </tr>
    </tbody>
</table>

<!--
        <table style="width:120%;" cellpadding="0" cellspacing="0" class="table table-bordered  table-hover">

        <tr>
                <th><?php echo $this->Paginator->sort('name'); ?></th>
                <th><?php echo $this->Paginator->sort('email'); ?></th>
                <th><?php echo $this->Paginator->sort('phone'); ?></th>
                <th  style="width:8%;"><?php echo $this->Paginator->sort('address'); ?></th>
                <th  style="width:50%;"><?php echo $this->Paginator->sort('note'); ?></th>
                <th style="width:50%;" class="actions"><?php echo __('Actions'); ?></th>
        </tr>

        <?php foreach ($consigners as $consigner): ?>
        <tr id="consigner_<?php echo h($consigner['Consigner']['id']); ?>" class="consigner">
            <td><?php echo $this->html->link($consigner['Consigner']['name'], array('controller' => 'consigners', 'action' => 'view', $consigner['Consigner']['id'])); ?>&nbsp;</td>
            <td><?php echo h($consigner['Consigner']['email']); ?>&nbsp;</td>
            <td><?php echo h($consigner['Consigner']['phone']); ?>&nbsp;</td>
            <td  style="width:8%;"><?php echo h($consigner['Consigner']['address']); ?>&nbsp;</td>
            <td  style="width:8%;"><?php echo h($consigner['Consigner']['note']); ?>&nbsp;</td>
            <td class="actions">
                <?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $consigner['Consigner']['id'])); ?>
                <?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $consigner['Consigner']['id']), null, __('Are you sure you want to delete # %s?', $consigner['Consigner']['id'])); ?>
            </td>
        </tr>
    <?php endforeach; ?>
        </table>-->
      <!-- <p>
        <?php
        echo $this->Paginator->counter(array(
        'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
        ));
        ?>	</p>-->
       <!-- <div class="paging">
        <?php
            echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
            echo $this->Paginator->numbers(array('separator' => ''));
            echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
        ?>
        </div>-->
    </div>


    <script type="text/javascript">
        //<![CDATA[
             var consigners = <?php echo json_encode($consigners);?>;

             $('#ConsignerKeyword').keyup(function(e) {
                 if (this.value != '') {
                     for (k in consigners) {
                         if (consigners[k]['Consigner'].name.toLowerCase() == this.value.toLowerCase() ||
                                 consigners[k]['Consigner'].phone.toLowerCase() == this.value.toLowerCase() ||
                                  consigners[k]['Consigner'].name.toLowerCase().indexOf(this.value.toLowerCase())>= 0 ||
                                  consigners[k]['Consigner'].phone.toLowerCase().indexOf(this.value.toLowerCase())>= 0
                                  ) {
                             $('#consigner_'+consigners[k]['Consigner'].id).show();
                         }
                         else {
                             $('#consigner_'+consigners[k]['Consigner'].id).hide();
                         }
                     }
                 }
                 else {
                     $('.consigner').show();
                 }
             });
        //]]>
    </script>


</div>